﻿using Ducu.BLL.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Global.Core.ExtensionMethod;
using Story = Ducu.GLB.Global.Story;
using Ducu.GLB.Story;
using BuildDatabase.Repository;

namespace BuildDatabase.Factory
{
    internal static class RegisterFactory
    {
        private readonly static string password = "1234".Md5Encypt();

        internal static void Create()
        {
            UserRepository.Yezi = register(Registers.Yezi);
            UserRepository.Abu = register(Registers.ABu);
            UserRepository.LuoMu = register(Registers.LuoMu);
            UserRepository.Mimi = register(Registers.Mimi);
        }

        private static User register(Register register)
        {
            User user = new User
            {
                RegisterInfo = register,
                Profile = new Profile {  DisplayName = register.UserName}
            };
            register.Password = password;
            register.SetPrivateField("_authCode", "123456");
            register.User = user;

            NHProvider.session.Save(user);

            return user;       
        }
    }
}
